<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 2.20</title>
</head>

<body>
<?php
	if(isset($_POST['soN']))
	{
		$n=$_POST['soN'];
		$kq="";
		//xet cac so tu 2 den n xem so do phai la snt hay khong
		for($i=2;$i<=$n;$i++)
		{
			//Kiem tra $i co phai la SNT k?
			//Neu la snt thi them vo chuoi
			$boolSNT=true;
			for($j=2;$j<$i;$j++)
				if($i%$j==0)
				{
					$boolSNT=false;break;
				}
			if($boolSNT==true)
			{
				$kq.=" $i ";
			}
		}
		$kq.="là số nguyên tố";
		ltrim($kq);
	}
?>
<form id="form1" name="form1" method="post" action="Bai2_20.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#FFCC66">
      <td colspan="2" style="text-align: center; font-family: 'Lucida Console', Monaco, monospace; font-size: 24px; color: #900;">TÌM SỐ NGUYÊN TỐ</td>
    </tr>
    <tr>
      <td bgcolor="#FFCC99">Nhập N: </td>
      <td bgcolor="#FFCC99"><input name="soN" type="text" id="soN" value="<?php echo $_POST['soN'];?>" /></td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#FFCC99" style="text-align: center"><input style="background-color:#FFC" type="submit" name="submit" id="submit" value="Các số nguyên tố &lt;= N" /></td>
    </tr>
    <tr style="text-align: center">
      <td colspan="2" bgcolor="#FFCC99"><input style="background-color:#FCF; color:#F00; font-weight:bold" name="kq" type="text" id="kq" value="<?php echo $kq;?>" size="70" /></td>
    </tr>
  </table>
</form>
</body>
</html>